
	package stbm.gui;

	import java.awt.*;

	import javax.swing.*;

	import java.awt.event.*;

	import stbm.guihelpers.*;
	import stbm.objects.*;

	/**
	 * The class representing the Game screen
	 * 
	 * @author Nisha L
	 * 
	 */
	public class FlyPanel extends BasicPanel  {
	    private Image spaceship;
	    private Image background;
	    private Timer timer;
	    private int x, y;
	    private Thread animation; 
	    
	    private final int DELAY = 50;
	    
		/**
		 * Creates a new FlyPanel with the supplied gameManager
		 * 
		 * @param gameManager
		 */
	    public FlyPanel(GameManager gameManager) {
	    	super(gameManager);
	    	
	    	this.addKeyListener(new DirectionListener());
	    	
	    }
	    
		/**
		 * Initializes the FlyPanel
		 */
	    public void build(){
	    	
	    	background = new ImageIcon("images/xdf_hubble_960.jpg").getImage();
	        spaceship = new ImageIcon("images/spaceship.jpg").getImage();

	    }
	    
		/**
		 * Draws the images
		 */
		public void paintComponent(Graphics g) {
			g.drawImage(background, 0, 0, null);
			g.drawImage(spaceship, x,y,null);
			
		}

/*		public void update() {
		        x += 1;
		        y += 1;

		        if (y > 240) {
		            y = -45;
		            x = -45;
		        } 
		 }*/

		/*
		 * ActionListener for movement of spaceship
		 */
		private class DirectionListener implements KeyListener{
			public void keyPressed(KeyEvent e){
				//Not working
				System.out.println("Switch screens");
				switch (e.getKeyCode()){
					case KeyEvent.VK_DOWN:
						System.out.println("Switch screens");
						gameManager.switchScreens(GameSpecifics.GAME_SCREEN);
						break; 
				}

			}
			
			public void keyTyped (KeyEvent e){};
			public void keyReleased(KeyEvent e){}; 
		}
	   

	}


